/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mapbar.pay.action;
import com.mapbar.pay.entity.User;
import com.mapbar.pay.service.UserService;
import com.mapbar.pay.util.Util;
import org.apache.log4j.Logger;
/**
 * 处理购买流程的价格选择的提交
 *创建时间 2010-3-9 16:24:29
 * @author fengbj
 */
public class BuySelectPriceProcessAction extends BaseAction{

    private Logger logger = Logger.getLogger(this.getClass()); //日志对象
    private String price;
    //private DeviceService deviceService;
    private UserService userService;
    private String needLogon;
    
    @Override
    public String execute(){
        if(price != null && !"".equals(price)){

            User user = getUser();
            if(user != null){
                 //保存价格信息
                Util.addCookie("price" , price);
                logger.info("用户"+ user +"提交价格:" + price);
                logger.info("刷新用户信息");

                //刷新用户信息，防止得到修改后的错误数据
                userService.refreshUserInfo(user);
                logger.info("刷新用户信息成功" + user);
                //test
                //user.setSerial(null);
                //检测是否捆绑了序列号
                if(user.getSerial() != null && !"".equals(user.getSerial().trim())){
                    
                    return "confirm";
                }else{
                    //用户没有绑定序列号
                    logger.info("用户没有绑定序列号");
                    return "serialIndex";
                }

            }else{
                needLogon = "true";
                return "input";
            }
        }else{
            logger.error("用户没有选择价格，可疑用户！");
            return "input";
        }
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public String getNeedLogon() {
        return needLogon;
    }




}
